import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";

import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
//引入弹出样式
import ElementPlus from "unplugin-element-plus/vite";

// Element自动导入 图标
import Icons from "unplugin-icons/vite";
import IconsResolver from "unplugin-icons/resolver";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      imports: ["vue", "vue-router", "pinia"],
      resolvers: [
        ElementPlusResolver(),
        // 自动导入图标组件
        IconsResolver({
          prefix: "Icon"
        })
      ],
      eslintrc: { enabled: false } //给eslint生产的配置 只需要一次
    }),
    Components({
      resolvers: [
        //自动注册图标组件
        IconsResolver({
          enabledCollections: ["ep"]
        }),
        ElementPlusResolver()
      ],
      dirs: ["src/components"]
    }),
    Icons({
      autoInstall: true
    }),
    ElementPlus({})
  ],

  resolve: {
    // alias: {
    //   find: "@",
    //   replacement: path.resolve(__dirname, "src")
    // }
    alias: {
      "@": resolve(__dirname, "src")
    }
  }
});
